#include "newAddressTab.h"
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "addDialog.h"

NewAddressTab::NewAddressTab(QWidget * parent /*= nullptr*/)
    :QWidget(parent)
{
    auto pDescriptionLabel = new QLabel(tr("There are currently no contacts in your address book. "
        "\nClick Add to add new contacts."), this);
    auto pAddBtn = new QPushButton(tr("Add"), this);

    auto pMainLayout = new QVBoxLayout(this);
    pMainLayout->addWidget(pDescriptionLabel);
    pMainLayout->addWidget(pAddBtn, 0, Qt::AlignCenter);

    setLayout(pMainLayout);

    connect(pAddBtn, &QPushButton::clicked, this, &NewAddressTab::addEntry);
}

NewAddressTab::~NewAddressTab()
{
}

void NewAddressTab::addEntry()
{
    AddDialog oDialog;
    if (oDialog.exec() == QDialog::Accepted)
    {
        sendDetails(oDialog.name(), oDialog.address());
    }
}
